//
//  JHPAY.m
//  JHPAY
//
//  Created by 颜 on 16/10/31.
//  Copyright © 2016年 Steven. All rights reserved.
//

#import "JHPAY.h"
#import "JHHtmlWebViewController.h"
@interface JHPAY()<JHWebPayDelegate>
@property(nonatomic,weak)id<JHPayDelegate>delegate;

@end
@implementation JHPAY
+ (void)presentApi:(NSString *)api viewController:(id<JHPayDelegate>)vc appId:(NSString *)appid payType:(NSString *)payType orderId:(NSInteger)orderId payAmount:(float)payAmount token:(NSString *)token;
{
    
//    NSString *str = @"http://hybapi-release.thy360.com/ja/memberbao1/pay/request/";
//    NSString *urlStr = [NSString stringWithFormat:@"%@%@%@%d%.2f?token=%@",str,@"appidzzerhuo0vyokl",@"order",457,11.00];
//    self.delegate = vc;
    NSString *urlStr = [NSString stringWithFormat:@"%@/%@/%@/%ld/%.2f/%@",api,appid,payType,(long)orderId,payAmount,token];
    JHHtmlWebViewController *tmpvc = [[JHHtmlWebViewController alloc] init];
    tmpvc.url = urlStr;
    tmpvc.delegate = vc;
    
    UIViewController *VC = (UIViewController *)vc;
    [VC.navigationController pushViewController:tmpvc animated:YES];
}
- (void)wxPay:(id)data
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(wxPay:)]) {
        [self.delegate wxPay:data];
    }
}
- (void)payCompleted
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(payCompleted)]) {
        [self.delegate payCompleted];
    }
}
@end
